package cn.haona.game.simb.wap.servlet.init.object;

import java.util.Iterator;
import java.util.List;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import cn.haona.game.simb.comm.util.IllWordFilterImplLocal;
import cn.haona.game.simb.object.department.HAB;
import cn.haona.game.simb.object.god.CacheManager;
import cn.haona.game.simb.object.god.EntityManager;
import cn.haona.game.simb.object.god.MainManager;
import cn.haona.game.simb.object.god.cache.CacheImpl_Memcached;
import cn.haona.game.simb.servlet.Util;
import cn.haona.game.simb.wap.servlet.WebDefine;

public class InitEntity {

	final public static String TAG_FILTER_LOCAL="illword_local";
	
	public void initMe(String fileName)
	{
		// 字符串
		String strXML = Util.getStringFromLoadFile(fileName);

		// 解析数据
		Document document;
		try {
			document = DocumentHelper.parseText(strXML);
			// 跟元素
			Element root = document.getRootElement();
			
			String illword_local=root.elementTextTrim(TAG_FILTER_LOCAL);
			
			String filePath=WebDefine.WEB_APP_REAL_PATH+illword_local;
			
			//实体管理器
			HAB hab=new HAB();
			EntityManager entityManager=new EntityManager();
			entityManager.setHab(hab);
			
			//词汇过滤器
			IllWordFilterImplLocal ifl=new IllWordFilterImplLocal(filePath);
			entityManager.setIllWordFilterLocal(ifl);
			
			//实体管理器放入总管理器中
			MainManager.getInstance().setEntityManager(entityManager);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
}
